package cn.zhibang.sannuo.web.controller;


import cn.zhibang.sannuo.commons.model.BranchOffice;
import cn.zhibang.sannuo.commons.model.Cudetails;
import cn.zhibang.sannuo.commons.utils.StringUtils;
import cn.zhibang.sannuo.user_detection.service.UBranchOfficeService;
import cn.zhibang.sannuo.user_detection.service.UCudetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping(value = "/userDetection")
public class UserDetectionController {

    @Autowired private UBranchOfficeService uBranchOfficeService;
    @Autowired private UCudetailsService uCudetailsService;

    /**
     * 检测者列表
     * @return
     */
    @GetMapping("/examiner_list")
    public String examiner_list(Model model){
        List<BranchOffice> branchOffice = uBranchOfficeService.getBranchOffice();
        model.addAttribute("branchOffice", branchOffice);
        return "html/examiner_list";
    }

    /**
     * 新增检测者
     * @return
     */
    @GetMapping("/examiner_add")
    public String examiner_add(){
        return "html/examiner_add";
    }

    /**
     * 检查
     * @return
     */
    @GetMapping("/examiner_add_list")
    public String examiner_add_list(){
        return "html/examiner_add_list";
    }

    /**
     * 检测项目
     * @return
     */
    @GetMapping("/examiner_projects")
    public String examiner_projects(String[] cuids,Model model){
        String cuid = StringUtils.stringArray(cuids);
        List<Cudetails> cudetailsByid = uCudetailsService.getCudetailsByid(cuid);
        model.addAttribute("cudetailsByid",cudetailsByid);
        return "html/examiner_projects";
    }


}
